#!/usr/bin/env python3
# -*- coding: utf-8 -*-

''

class Animal(object):
    def run(self):
        print(self.__class__.__name__  + ' is running')

class Dog(Animal):
    def eat(self):
        print(self.__class__.__name__ + ' eating bone')

class Cat(Animal):
    def run(self): # 多态
        print('Cat is running')



animal = Animal()
animal.run() # Animal is running

dog = Dog()
dog.run() # Dog is running
dog.eat() # Dog eating bone

cat = Cat()
cat.run() # Cat is running

print(isinstance(cat,Cat)) # True
print(isinstance(cat,Animal)) # True


# 多态验证：
class Test(object):
    def testdt(self,animal):
        animal.run()

ts = Test()
ts.testdt(animal) # Animal is running
ts.testdt(dog) # Dog is running
ts.testdt(cat) # Cat is running

# 动态的Python语言
class Timwe():
    def run(self):
        print('我不是Animal或它的子类啊，我也能调用test')

tm = Timwe()
ts.testdt(tm) # 我不是Animal或它的子类啊，我也能调用test